<!-- quirks -->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta name="renderer" content="webkit"/>
	<title>数组操作</title>
	<link href="../../ting-quirks.css" rel="stylesheet"/>
	<!--[if lt IE 9]><script src="../../dist/sky-compat.js"></script><![endif]-->
	<!--[if gte IE 9]><!--><script src="../../dist/sky-modern.js"></script><!--><![endif]-->
	<script src="../../demo.js"></script>
</head>
<body>
	<div class="container-fluid">
		<h2>数组操作</h2>
		<h3>Sky.findIndex</h3>
		<p>查找对象数组编号</p>
<pre class="code">var users = [
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':11 }
];

Sky.findIndex(users,"user","fred");
// => 1
Sky.findIndex(users,"user","barney");
// => 0
Sky.findIndex(users,"user","tom");
// => -1</pre>
		<h3 id="findLastIndex">Sky.findLastIndex</h3>
		<p>该方法类似findIndex ，区别是其从右到左遍历数组。</p>
<pre class="code">var users = [
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':11 },
	{ 'user': 'fred','age':13 }
];

Sky.findLastIndex(users,"user","fred");
// => 2</pre>
		<h3 id="find">Sky.find</h3>
		<p>查找对象数组中的对象。</p>
<pre class="code">var users = [
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':11 }
];

Sky.find(users,"user","fred");
// => { 'user': 'fred','age':11 }</pre>
		<h3 id="findLast">Sky.findLast</h3>
		<p>该方法类似find ，区别是其从右到左遍历数组。</p>
<pre class="code">var users = [
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':11 },
	{ 'user': 'fred','age':13 }
];

Sky.findLast(users,"user","fred");
// => { 'user': 'fred','age':13 }</pre>
		<h3 id="shuffle">Sky.shuffle</h3>
		<p>打乱数组顺序。</p>
		<div class="btn-toolbar">
			<a class="btn btn-primary" href='javascript:alert(Sky.shuffle([1,2,3,4,5]).join(","))'>测试</a>
		</div>
		<h3 id="sortBy">Sky.sortBy</h3>
		<p>按照对象数组中的字段排序。</p>
<pre class="code">var users = [
	{ 'user': 'pebbles','age':11 },
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':13 }
];

Sky.sortBy(users, 'user');</pre>
		<h3 id="pluck">Sky.pluck</h3>
		<p>对象数组转化为普通数组。</p>
<pre class="code">var users = [
	{ 'user': 'pebbles','age':11 },
	{ 'user': 'barney' ,'age':10 },
	{ 'user': 'fred','age':13 }
];

Sky.pluck(users, 'user');
// => ['pebbles','barney','fred']</pre>
		<h3 id="sortedIndex">Sky.sortedIndex</h3>
		<p>返回value 应该插入数组array位置的索引值</p>
<pre class="code">Sky.sortedIndex([30, 50], 40);
// => 1

Sky.sortedIndex([4, 4, 5, 5], 5);
// => 2</pre>
		<h3 id="sortedLastIndex">Sky.sortedLastIndex</h3>
		<p>用法类似于sortedIndex ,不同的是从右至左计算插入的位置</p>
<pre class="code">Sky.sortedLastIndex([4, 4, 5, 5], 5);
// => 4</pre>
		<h3 id="times">Sky.times</h3>
		<p>循环N次</p>
<pre class="code">Sky.times(5, function(){
	// ...
});</pre>
		<div class="btn-toolbar">
			<a class="btn btn-primary" href='javascript:Sky.times(5, function(){alert("哈")});'>试一试</a>
		</div>
	</div>
</body>
</html>